<%--                                                                       --%>
<%-- Copyright (c) 2003-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.broadvision.ssp.client.SspInstance" %>
<%@ page import="com.broadvision.ssp.client.SspInstanceState" %>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%
  String ctxPath = request.getContextPath();
%>

<jsp:useBean id="bpProcessInstanceSearchForm" 
          class="com.broadvision.process.tools.action.process.ProcessInstanceSearchForm"
          scope ="request"/>

<c:set var="editImg">
<img src="<%= ctxPath %>/mc/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.edit" bundle="mc.messages"/>" title="<bean-el:message key="image.alt.edit" bundle="mc.messages"/>">
</c:set>
<c:set var="outlineImg">
<img src="<%= ctxPath %>/bp/images/action/icon_viewsteps.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean:message key="bp.process.processInstanceSearch.icon.outline" bundle="bp.messages"/>"/>
</c:set>
<c:set var="diagramImg">
<img src="<%= ctxPath %>/bp/images/action/icon_diagram.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean:message key="bp.process.processInstanceSearch.icon.diagram" bundle="bp.messages"/>" />
</c:set>

<html-el:form action="/bp/processInstanceSearch.do?action=search">
<!--start zone 5 content area-->

    <table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message key="bp.process.processInstance.contentArea" bundle="bp.messages"/>">
    <tr> 
		    <td valign="top" width="100%">
		      <div class="pageTitle"><bean:message key="bp.process.processInstanceMine.title" bundle="bp.messages"/>                       
            : <c:out value="${bpProcessInstanceSearchForm.resultSize}"/>
            <bean:message key="bp.process.processInstanceMine.found" bundle="bp.messages"/></div> 


<!--start subtitle row-->
    <div class="pageSubtitle">
    <span class="left">
    <bean:message key="bp.process.processInstanceMine.imanager" bundle="bp.messages"/>
    <% SspInstance[] sspis = bpProcessInstanceSearchForm.getSearchResults();%>
    <%= sspis.length %>
    <bean:message key="bp.process.processInstanceMine.instance" bundle="bp.messages"/></span><span class="right">&nbsp;</span>
    </div>

<!--end subtitle row-->
<!-- Start subtitle buttons row -->

<!-- End subtitle buttons row -->
        
            <!-- Start List here -->
<logic:greaterThan name="bpProcessInstanceSearchForm"
                               property="resultSize" value="0">
              
             <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
		      <tr class="listHeader">  
                <th valign="top" id="processName" align="left"><bean:message key="bp.process.processInstanceSearch.option.instanceName" bundle="bp.messages"/></th>
                <th valign="top" id="launchUser"  align="left"><bean:message key="bp.process.processInstanceSearch.option.launchUser" bundle="bp.messages"/></th>
                <th valign="top" id="launchDate"  align="left"><bean:message key="bp.process.processInstanceSearch.option.launchDate" bundle="bp.messages"/></th>
                <th valign="top" id="dueDate" align="left"><bean:message key="bp.process.processInstanceSearch.option.dueDate" bundle="bp.messages"/></th>
                <th valign="top" id="status" align="left"><bean:message key="bp.process.processInstanceSearch.text.status" bundle="bp.messages"/></th>
                <th valign="top" id="actions" align="left" nowrap><bean:message key="bp.process.processInstanceSearch.action" bundle="bp.messages"/></th>
              </tr>
              <%  
                for (int i=0; i < sspis.length; i++) {
                 SspInstance sspi = sspis[i];
                 Map dates = new HashMap();
                 dates.put("beginDate",sspi.getColumnDate("CREATION_TIME"));
                 dates.put("dueDate",sspi.getDueDate());
                 
                 pageContext.setAttribute("dates",dates);             
                 if ( ( i % 2 ) == 0 ) { %>
                    <tr class="listEven"> 
              <% }else{ %>
              <tr class="listOdd">
              <% } %>
                  <td valign="top"  headers="processName">
                    <a href="<%= response.encodeURL(ctxPath + "/bp/processInstance.do?instanceOid="+ sspi.getOid())%>" ><%= sspi.getCustomId() %></a>
                  </td>
                  <td valign="top"  headers="launchUser">
                    <%= sspi.getLaunchUser()%>
                  </td>
                  <td valign="top" headers="launchDate"><bean:write name="dates" property="beginDate" formatKey="format.datetime.short" bundle="mc.messages"/>
                  </td>
                  <td valign="top" headers="dueDate">
                    <bean:write name="dates" property="dueDate" formatKey="format.datetime.short" bundle="mc.messages"/></td>
                  <td valign="top" headers="status">
                    <bean:message key="<%=\"bp.process.processInstance.state.\"+ sspi.getState().getIntCode() %>" bundle="bp.messages"/></td>
                  <td valign="top" nowrap align="left" 
                    headers="actions">

                <% if (sspi.getState().getIntCode()<SspInstanceState.COMPLETED_STATE.getIntCode()) { %><a href="<%=response.encodeURL( ctxPath + "/bp/processInstance.do?action=edit&instanceOid="+ sspi.getOid())%>" >
                <c:out value='${editImg}' escapeXml="false"/></a>
                <% } %>
                <a href="<%= response.encodeURL(ctxPath + "/bp/processInstanceTasks.do?instanceOid="+ sspi.getOid())%>" ><c:out value='${outlineImg}' escapeXml="false"/></a>
                <a href="<%= response.encodeURL(ctxPath + "/bp/processInstanceDiagram.do?instanceOid="+ sspi.getOid())%>" ><c:out value='${diagramImg}' escapeXml="false"/></a>
                </td>
              </tr>
<!--end list here-->
           <% } // end of loop %>
            </table>
           </logic:greaterThan>
           

           <% if (bpProcessInstanceSearchForm.getResultSize()<=0) { %>
            <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
		      <tr class="listHeader">  
                <th valign="top" id="processName" align="left"><bean:message key="bp.process.processInstanceSearch.option.instanceName" bundle="bp.messages"/></th>
                <th valign="top" id="launchUser"  align="left"><bean:message key="bp.process.processInstanceSearch.option.launchUser" bundle="bp.messages"/></th>
                <th valign="top" id="launchDate"  align="left"><bean:message key="bp.process.processInstanceSearch.option.launchDate" bundle="bp.messages"/></th>
                <th valign="top" id="dueDate" align="left"><bean:message key="bp.process.processInstanceSearch.option.dueDate" bundle="bp.messages"/></th>
                <th valign="top" id="status" align="left"><bean:message key="bp.process.processInstanceSearch.text.status" bundle="bp.messages"/></th>
                <th valign="top" id="actions" align="left" nowrap><bean:message key="bp.process.processInstanceSearch.action" bundle="bp.messages"/></th>
              </tr>
               <tr class="listEven"> 
                  <td colspan="6" valign="top" align="center"><bean:message key="bp.process.processInstanceMine.nofound" bundle="bp.messages"/>
                  </td>
               </tr>
            </table>
           <% } %>
               
    </td>
  </tr>
</table>

<!--end main content area here-->
<!--end zone 5 content area-->

</html-el:form>


